package com.jml.mapreduce.自定义排序;

import com.jml.mapreduce.WritableComparable.FlowBean;
import org.apache.hadoop.io.RawComparator;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * WritableComparator的compare方法会被调用
 */
public class FlowComparator extends WritableComparator {

    public FlowComparator() {
        super(FlowBean.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        FlowBean fa = (FlowBean)a;
        FlowBean fb = (FlowBean)b;
        return Long.compare(fb.getSumFlow(), fa.getSumFlow());
    }
}
